﻿#region

using System.Data.Entity.ModelConfiguration;
using HouseHoldBudget.Core.Entities.Budgets;

#endregion

namespace HouseHoldBudget.Data.Mapping.Budgets
{
    public class BudgetCategoryMap : EntityTypeConfiguration<BudgetCategory>
    {
        #region Constructors

        public BudgetCategoryMap()
        {
            ToTable("BudgetCategory");
            HasKey(c => c.Id);
            

            Property(u => u.BudgetCategoryName);
            Property(u => u.RepartitionAmount);

            HasRequired(fp => fp.Budget)
                .WithMany(c => c.BudgetCategories)
                .HasForeignKey(fp => fp.BudgetId)
                .WillCascadeOnDelete(false);

            HasMany(p => p.ExpenseTypes)
                .WithMany()
                .Map(m => m.ToTable("BudgetCategory_ExpenseType_Mapping"));
        }

        #endregion
    }
}